<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
require_once "java/text/DecimalFormat.php";
/**
 * Description of IstatistikAraclari
 *
 * @author acer
 * Tested in 25.12.2011 15:26
 */
class IstatistikAraclari {
    //put your code here
    
    private static $_df;
    
    private static $_df2;
    
    public static function df() {
        if(is_null(self::$_df)) {
            self::$_df = new DecimalFormat("#0.000");
        }
        return self::$_df;
    }
    
    public static function df2() {
        if(is_null(self::$_df2)) {
            self::$_df2 = new DecimalFormat("#0.00000");
        }
        return self::$_df2;
    }
    
    /**
     *
     * @param float $input
     * @param float $total
     * @return float
     */
    public static function yuzdeHesapla($input, $total) {
        if($total == 0) {
            return -1;
        }
        return floatval( ($input * 100) / $total );
    }
 
    /**
     *
     * @param float $input
     * @param float $total
     * @return float 
     */
    public static function yuzdeHesaplaStr($input, $total) {
        if($total == 0) {
            return "0";
        }
        $df = self::df();
        return $df->format( floatval(($input * 100) / $total));
    }
    
    /**
     *
     * @param float $input
     * @param float $total
     * @return float
     */
    public static function onbindeHesaplaStr($input, $total) {
        if($total  == 0) {
            return "0";
        }
        $df2 = self::df2();
        return $df2->format( floatval(($input * 100) / $total));
    }
}